﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Asteriods
{
    class shipInput : GameObject
    {
        Input input;
        const float THRUST_MULTIPIER = 0.02f;
        public shipInput(Game game, string imagepath, Input input)
            : base(game, imagepath)
        {
            this.input = input;
        }
        public override void Update(GameTime gameTime, GraphicsDevice graphicsDevice)
        {
            if (input.MousePosition != new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2))
                Rotation = (float)Math.Atan2((double)
                    (input.MousePosition.Y - (graphicsDevice.Viewport.Height / 2)),
                    (input.MousePosition.X - (graphicsDevice.Viewport.Width / 2))) + MathHelper.PiOver2;
            if (input.HoldRightClick())
            {
                Velocity += (new Vector2((float)Math.Sin(Rotation), -(float)Math.Cos(Rotation))) * THRUST_MULTIPIER;
            }
            

            base.Update(gameTime, graphicsDevice);
        }
    }
}
